Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contextually validate expiration months based on current year. #13

Merged
merged 2 commits into from
Jun 23, 2015

Conversation

kyledetella
Copy link
Contributor

This will render previous months in the current year invalid.

Expiration date

// Current date: 06/2015
var validator = require('card-validator');

validator.expirationDate('01/2015'); // => {isValid: false, isPotentiallyValid: false ...}
validator.expirationDate('05/2015'); // => {isValid: false, isPotentiallyValid: false ...}
validator.expirationDate('06/2015'); // => {isValid: true, isPotentiallyValid: true ...}
validator.expirationDate('07/2015'); // => {isValid: true, isPotentiallyValid: true ...}

Expiration Month

validator.expirationMonth('01'); // => {isValid: true, isPotentiallyValid: true, isValidForThisYear: false}
validator.expirationMonth('05'); // => {isValid: true, isPotentiallyValid: true, isValidForThisYear: false}
validator.expirationMonth('06'); // => {isValid: true, isPotentiallyValid: true, isValidForThisYear: true}
validator.expirationMonth('07'); // => {isValid: true, isPotentiallyValid: true, isValidForThisYear: true}

Expiration Year

validator.expirationYear('2014'); // => {isValid: false, isPotentiallyValid: false, isCurrentYear: false}
validator.expirationYear('2015'); // => {isValid: true, isPotentiallyValid: true, isCurrentYear: true}
validator.expirationYear('2016'); // => {isValid: true, isPotentiallyValid: true, isCurrentYear: false}

@EvanHahn
Copy link
Contributor

I looked at this with Kyle and thought it was good

@mrak
Copy link
Contributor

mrak commented Jun 23, 2015

:shipit:

kyledetella added a commit that referenced this pull request Jun 23, 2015
Contextually validate expiration months based on current year.
@kyledetella kyledetella merged commit 07deb8f into master Jun 23, 2015
@kyledetella kyledetella deleted the validate-months-based-on-year branch June 23, 2015 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants